const jsonServer = require('json-server')
const server = jsonServer.create()
const apiRouter = jsonServer.router('db.json') // 此处的db.json是与package.json在同一目录下
const middlewares = jsonServer.defaults()
server.get('/egis-scms-app/app/queryWechatToken.dox', (res, req, next) => {
  let getToken = {
    'cacheValue': 'Y',
    'returnFlag': '200',
    'returnMsg': '',
    'status': '200'
  }
  req.jsonp(getToken)
})
server.post('/egis-scms-app/app/cache/getRedisCache.dox', (res, req, next) => {
  let resData = {
    'cacheValue': 'Y',
    'returnFlag': '200',
    'returnMsg': '我是mock接口',
    'port': '端口号http://localhost:3000',
    'status': '200'
  }
  req.jsonp(resData)
})

server.use(middlewares)
server.use(apiRouter)
server.listen(3000, () => { // 监听端口
  console.log('JSON Server is running')
  console.log('http://localhost:3000')
})
